<template>
	<div>
		<div class="list" v-if="list.length >0">
			<div class="item" v-for="(item,index) in list" :key="index" @click="toDetails(item)">
				<div class="text">{{ item.name }}</div>
				<div class="date">{{ item.date }}</div>
			</div>
		</div>
		<div class="empty" v-else>{{ emptyText }}</div>
	</div>
</template>

<script>
	export default {
		name: 'list',
		props: {
			list: {
				type: Array,
				default () {
					return []
				}
			},
			emptyText: {
				type: String,
				default: ""
			}
		},
		data() {
			return {

			}
		},
		created() {

		},
		methods: {
			toDetails(item) {
				localStorage.setItem('details', JSON.stringify(item));
				this.$router.push({
					path: '/details_page'
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.list {
		width: 1200px;
		margin: 0 auto;

		.item {
			display: flex;
			justify-content: space-between;
			height: 50px;
			line-height: 50px;
			cursor: pointer;
			color: #474747;

			.text {
				padding-left: 15px;
				width: 1000px;
				word-break: keep-all;
				white-space: nowrap;
				text-overflow: ellipsis;
				overflow: hidden;
			}

			.date {
				padding-right: 15px;
			}
		}

		.item:hover {
			color: #255389
		}

		.item:nth-of-type(odd) {
			background-color: #eeeaf3;
		}
	}

	.empty {
		font-weight: 600px;
		margin: 50px 0;
		text-align: center;
	}
</style>
